{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import h5py\n",
    "import matplotlib.pyplot as plt\n",
    "from datetime import datetime, timedelta\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "lat_min, lat_max = 31.1, 31.4\n",
    "lon_min, lon_max = 121.3, 121.8\n",
    "lat_ctr = (int)((lat_max - lat_min) / 0.005)\n",
    "lon_ctr = (int)((lon_max - lon_min) / 0.005)\n",
    "\n",
    "def lat_quantize(lat):\n",
    "    return (int)((lat - lat_min) / 0.005)\n",
    "def lon_quantize(lon):\n",
    "    return (int)((lon - lon_min) / 0.005)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def extract_hist(data):\n",
    "    hist, xedges, yedges = np.histogram2d(data['lat'], data['lon'],\n",
    "        bins = [range(lat_ctr), range(lon_ctr)],\n",
    "        range=[[0, lat_ctr], [0, lon_ctr]])\n",
    "    hist = hist.astype(\"int\")\n",
    "    return hist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_density_hour(data, hour_begin, hour_end):\n",
    "    data_hour = data[(hour_begin <= data['date_time']) & (data['date_time'] < hour_end)]\n",
    "    data_hour['lat'] = data_hour['lat'].apply(lambda lat:\n",
    "        (int)((lat-lat_min) / 0.005))\n",
    "    data_hour['lon'] = data_hour['lon'].apply(lambda lon:\n",
    "        (int)((lon-lon_min) / 0.005))\n",
    "    data_hour = data_hour.drop_duplicates(['car_id', 'lat', 'lon'])\n",
    "    hist  = extract_hist(data_hour)\n",
    "    return hist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_range_density(hist, range_xy):\n",
    "    center_lat = lat_quantize((range_xy[0][0] + range_xy[0][1]) / 2)\n",
    "    center_lon = lon_quantize((range_xy[1][0] + range_xy[1][1]) / 2)\n",
    "    return (hist[center_lat][center_lon])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_dataset(month, day):\n",
    "    frames = []\n",
    "    features_need = ['car_id', 'date_time', 'lat', 'lon']\n",
    "    rcar_dtype = {'car_id': str,\n",
    "                  'date_time': str,\n",
    "                  'lat': float,\n",
    "                  'lon': float,\n",
    "                  'power_mode': str,\n",
    "                  'mileage': float,\n",
    "                  'speed': float,\n",
    "                  'fuel_consumption': float}\n",
    "    ecar_dtype = {'car_id': str,\n",
    "                  'date_time': str,\n",
    "                  'lat': float,\n",
    "                  'lon': float,\n",
    "                  'work_mode': str,\n",
    "                  'mileage': float,\n",
    "                  'speed': float,\n",
    "                  'avg_fuel_consumption': float,\n",
    "                  'system_mode': str}\n",
    "    date = datetime.strftime(datetime(2017, month, day), \"%Y%m%d\")\n",
    "    for part in range(3):\n",
    "        filename = (\"./data/rcar/BOT_data_rcar_{1}_{1}_part{0}.csv\"\n",
    "                    .format(part, date))\n",
    "        data_part = pd.read_csv(filename, dtype=rcar_dtype)[features_need]\n",
    "        data_part = data_part[(data_part['lat'] > 0.1) & (data_part['lon'] > 0.1)]\n",
    "        frames.append(data_part)\n",
    "        \n",
    "        filename = (\"./data/ecar/BOT_data_ecar_{1}_{1}_part{0}.csv\"\n",
    "                    .format(part, date))\n",
    "        data_part = pd.read_csv(filename, dtype={'system_mode': str})[features_need]\n",
    "        data_part = data_part[(data_part['lat'] > 0.1) & (data_part['lon'] > 0.1)]\n",
    "        frames.append(data_part)\n",
    "        \n",
    "    data = pd.concat(frames)\n",
    "    data[\"date_time\"] = data[\"date_time\"].apply(lambda x: datetime.strptime(x, \"%Y-%m-%d %H:%M:%S\"))\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20170102\n"
     ]
    }
   ],
   "source": [
    "date = datetime.strftime(datetime(2017, 1, 2), \"%Y%m%d\")\n",
    "print(date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "get_dataset() missing 2 required positional arguments: 'month' and 'day'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-10-adcedcf166da>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_dataset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: get_dataset() missing 2 required positional arguments: 'month' and 'day'"
     ]
    }
   ],
   "source": [
    "data = get_dataset()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "hist = get_density_hour(data, datetime(2017, 3, 6, 9),\n",
    "                       datetime(2017, 3, 6, 9+1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "with h5py.File(\"./data/hist/test.h5\", \"w\") as f:\n",
    "    f.create_dataset('test', data=hist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/jachinshen/Projects/python/bot/env/lib/python3.7/site-packages/ipykernel_launcher.py:3: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  This is separate from the ipykernel package so we can avoid doing imports until\n",
      "/home/jachinshen/Projects/python/bot/env/lib/python3.7/site-packages/ipykernel_launcher.py:5: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  \"\"\"\n"
     ]
    }
   ],
   "source": [
    "def store_hist():\n",
    "    date = datetime(2017, 1, 2)\n",
    "    delta_day = timedelta(days=1)\n",
    "    while date <= datetime(2017, 1, 2):\n",
    "        date_str = datetime.strftime(date, \"%Y%m%d\")\n",
    "        with h5py.File(\"./data/hist/{}.h5\".format(date_str), \"w\") as f:\n",
    "            for hour in range(9, 13):\n",
    "                data = get_dataset(date.month, date.day)\n",
    "                hist = get_density_hour(data, datetime(2017, date.month, date.day, hour),\n",
    "                                       datetime(2017, date.month, date.day, hour+1))\n",
    "                f.create_dataset('hour: {}'.format(hour), data=hist)\n",
    "        date += delta_day\n",
    "        \n",
    "store_hist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Keys: ['hour: 10', 'hour: 11', 'hour: 12', 'hour: 9']\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAADnCAYAAAAO5q0KAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJztnXuMJNd13r/TPa/d2edwZ3dn3ytyxaf4ECmKMmVJESWbesCUE0Gh5AREwIT/KInsOJBoAQHsIAakwLBs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PPwuvEXMa2jfxfAJkxno/yUc+54VzrZBUTkAwD+o3Pu4yLyNkw/sY8AeBbAv3DO9V7FkHlARG7G9AviAQCvA/hXmH7oWnD3hoj8AYB/jmln2LMA/jWmNfMFeW+kwkhRQggpCHwpSgghBYEDOiGEFAQO6IQQUhA4oBNCSEHggE4IIQWBAzohhBQEDuiEEFIQOKATQkhB+P9whu4sAPM5JwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "with h5py.File(\"./data/hist/20170103.h5\", \"r\") as f:\n",
    "    print(\"Keys: {}\".format(list(f.keys())))\n",
    "    data = f['hour: 9']\n",
    "    plt.imshow(data)\n",
    "    plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
